﻿<!--
   Copyright (c) 2011, Microsoft Corporation
  
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
  
       http://www.apache.org/licenses/LICENSE-2.0
  
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->
<UserControl
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" xmlns:ee="http://schemas.microsoft.com/expression/2010/effects" xmlns:local="clr-namespace:Microsoft.Samples.ServiceBus.SilverlightChat"
  xmlns:vc="clr-namespace:Microsoft.Samples.ServiceBus.SilverlightChat.Models.ValueConverters"
  mc:Ignorable="d"
  x:Class="Microsoft.Samples.ServiceBus.SilverlightChat.ChatWindow"
  d:DesignWidth="640" d:DesignHeight="480">

    <Grid x:Name="LayoutRoot">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="SubscriptionStates">
                <VisualState x:Name="Subscribed"/>
                <VisualState x:Name="Unsubscribed">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="border1">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimation Duration="0" To="21.333" Storyboard.TargetProperty="(TextBlock.FontSize)" Storyboard.TargetName="textBlock" d:IsOptimized="True"/>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
            <VisualStateGroup x:Name="SelectionStates">
                <VisualState x:Name="NothingSelected">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="border">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="TopicSelected">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="border">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <Grid.RowDefinitions>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <StackPanel Margin="0,456,0,0" VerticalAlignment="Bottom" Orientation="Horizontal" Grid.ColumnSpan="2" OpacityMask="#CC000000">
            <StackPanel.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Offset="0.25" Color="#00101010"/>
                    <GradientStop Color="#FF101010" Offset="1"/>
                </LinearGradientBrush>
            </StackPanel.Background>
            <Image Height="16" Source="Resources/Star-Disabled.png" Width="16" Margin="8,4,4,4"/>
            <TextBlock TextWrapping="Wrap" Text="Click to Subscribe" Foreground="Silver" Margin="4,0,0,0" VerticalAlignment="Center"/>
        </StackPanel>
        <Grid HorizontalAlignment="Left" Width="200">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <TextBlock HorizontalAlignment="Left" Margin="4,0" TextWrapping="Wrap" Text="Topics" Foreground="White" VerticalAlignment="Center" FontFamily="Segoe UI Semibold" FontSize="12"/>
            <Button Command="{Binding AddTopicCommand}" d:LayoutOverrides="Height" Grid.Column="1" Background="{x:Null}" BorderBrush="{x:Null}" Style="{StaticResource EmptyButtonStyle}" ToolTipService.ToolTip="Create a New Topic" Margin="0,0,4,0">
                <Image Height="16" Width="16" Source="Resources/Plus.png" Stretch="UniformToFill" Cursor="Hand"/>
            </Button>
            <ListBox x:Name="chatTopics" ItemsSource="{Binding Topics}" SelectedItem="{Binding CurrentTopic, Mode=TwoWay}" SelectionMode="Single" SelectionChanged="OnSelectedTopicChanged" Background="{x:Null}" BorderBrush="{x:Null}" Margin="2,0,0,0" Grid.ColumnSpan="2" Grid.Row="1" FontSize="14.667" FontFamily="Segoe UI Semibold" ItemTemplate="{StaticResource ChatTopicListItemStyle}" ItemContainerStyle="{StaticResource ChatTopicListItemContainer}" HorizontalContentAlignment="Stretch"/>
        </Grid>
        <Border x:Name="border" BorderBrush="#FF606060" BorderThickness="1" CornerRadius="8" Background="#FFF0F0F0" Margin="2,4,4,4" Grid.Column="1" Visibility="Collapsed">
            <Grid Margin="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <RichTextBox x:Name="currentChatTextBox" Margin="8,8,8,0" BorderBrush="Silver" Grid.ColumnSpan="2" IsReadOnly="True"/>
                <TextBlock Text="{Binding CurrentMessage.UserName, StringFormat=\{0\}&gt;}" TextWrapping="Wrap" Grid.Row="1" VerticalAlignment="Center" Margin="8,8,0,8" FontSize="12" FontWeight="Bold"/>
                <TextBox Text="{Binding CurrentMessage.Value, Mode=TwoWay}" TextInput="OnChatMessageBoxTextInput" x:Name="chatMessageTextBox" TextWrapping="Wrap" VerticalAlignment="Top" Grid.Row="1" Margin="8" BorderBrush="Silver" Grid.Column="1"/>
                <Border x:Name="border1" Grid.ColumnSpan="2" Margin="8,8,8,0" d:LayoutOverrides="Width" Background="#7F000000" Visibility="Collapsed">
                    <TextBlock x:Name="textBlock" TextWrapping="Wrap" Text="You aren't subscribed to this room. Click the Star next to the topic name to become a subscriber." Foreground="White" FontSize="18.667" HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center"/>
                </Border>
            </Grid>
        </Border>
    </Grid>
</UserControl>